<template>
	<view>
		<uni-swipe-action v-for="(item,index) in cartList">
			<uni-swipe-action-item>
				<view class="content-box">
					<view class="flex padding" >
						<view class="flex align-center">
							<text 
								class="iconfont icon-gouxuan margin-right"
								:class="item.ischeck?'text-yellow':'text-grey'"
								@click="handleCheck(index)"
							></text>
							<image class="poster margin-right" :src="item.img" mode=""></image>
						</view>
						<view class="flex justify-between info list">
							<view class="">
								{{item.name}}
								<view class="margin-tb-xs">{{item.french}}</view>
								<view class="text-price">
									{{item.list[item.dropIdx].price}}
								</view>
							</view>
							<view class="flex flex-direction align-end">
								<view @click="handlePopShow(item,index)" class="edit margin-bottom-xs">
									<text class="iconfont icon-bianji"></text>
								</view>
								{{item.list[item.dropIdx].spec}}
								 X 
								{{item.num}}
							</view>
						</view>
					</view>
					
				</view>
				<template v-slot:right>
					<view class="slot-button" @click="handleDel(index)">
						<text class="slot-button-text">删除</text>
					</view>
				</template>
			</uni-swipe-action-item>
		</uni-swipe-action>
		
		<view class="cu-bar foot bg-fff flex">
			<view class="flex flex-sub padding align-center">
				<text 
					class="iconfont icon-gouxuan margin-right-xs"
					:class="allInfo.allCheck?'text-yellow':'text-grey'"
					@click="handleAllCheck(allInfo.allCheck)"
				></text>全选
				<view class="margin-left">
					共计:{{allInfo.allPrice}}
				</view>
			</view>
			<view @click="handleOrder" class="bg-yellow padding text-center color-fff">
				立即结算
			</view>
		</view>
		<good-spec></good-spec>
	</view>
</template>

<script>
	import {mapState,mapGetters,mapMutations} from 'vuex'
	import {myMapMutations} from '../../utils/vuexMap.js'
	export default {
		computed:{
			// cityname:()=>{
			// 	return this.$store.state.city.cityname
			// },
			// cartList:()=>{
			// 	return this.$store.state.cart.cartList
			// },
			// 等同于
			...mapState({
				cartList:state=>state.cart.cartList,
				cityname:state=>state.city.cityname
			}),
			...mapGetters({
				allInfo:'cart/allInfo'
			})
		},
		methods:{
			handlePopShow(cartObj,idx){
				this.$store.commit('cart/cartPopDataMut',{
					cakeObj:cartObj,
					editIdx:idx
				}) //设置弹窗数据
				this.$store.commit('cart/cartPopShowMut',true)
			},
			// handleCheck(idx){
			// 	this.$store.commit('cart/cartCheckMut',idx)
			// },
			// ...mapMutations({
			// 	handleCheck:'cart/cartCheckMut'
			// }),
			...myMapMutations({
				handleCheck:'cart/cartCheckMut',
				handleAllCheck:'cart/cartAllCheckMut',
				handleDel:'cart/cartDelMut'
			}),
			handleOrder(){
				if(this.allInfo.allPrice==0){
					uni.showToast({
						title:'请选择结算的商品',
						icon:'none'
					})
					return
				}
				uni.navigateTo({
					url:'/pages/order/order'
				})
			}
		}
	}
</script>

<style lang="scss">
page{
	padding-bottom: 100upx;
	background-color: #fff;
}
.poster{
	width: 180upx;
	height: 180upx;
	background-color: #d8d8d8;
}
.info{
	&.list{
		width: 60%;
	}
	.edit{
		width: 80upx;
		height: 80upx;
		text-align: center;
		line-height: 80upx;
		background-color: #e6e6e6;
		border-radius: 50%;
		
	}
}
.flex.align-end{
	min-width: 210upx;
}
// .icon-gouxuan{
// 	color: #e7e7e7;
// }
.cu-btn.lg{
	width: 50%;
}
.cover-cont{
	position: absolute;
	top: 50%;
	left: 0;
	width: 690upx;
	transform: translateY(-50%);
	border-radius: 10upx;
}
.drop{
	position: relative;
	.drop-list{
		width: 300upx;
		position: absolute;
		top: 60upx;
		right: 0;
		box-shadow: 0 0 10upx 2upx rgba(0,0,0,0.2);
		z-index: 10;
		view:hover{
			background-color: #e6e6e6;
		}
	}
}
.foot.cu-bar{
	bottom: 100upx !important;
}
.slot-button{
	background-color: indianred;
	width: 100upx;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
}
</style>
